var dropload = {
  init: function() {
	this.el = document.querySelector('.content') || window;
	this.ele = document.querySelector('.content') || document.body;
    this.top = document.body.scrollTop;
    this.sh = document.documentElement.clientHeight;
    this.eh = document.body.scrollHeight;
    this.diff = this.eh - this.sh;
    this.t = this.diff - this.top;
  },
  scroll: function(callback) {
	this.init()
    var self = this;
    self.el.addEventListener('scroll', function() {
    	self.top = self.ele.scrollTop;
    	self.sh = document.documentElement.clientHeight;
    	self.eh = self.ele.scrollHeight;
    	self.diff = self.eh - self.sh;
      var t = self.diff - self.top;
      (callback && typeof(callback) === "function") && callback(t, self.top);
    });
    return this;
  },
  loadData: function(callback) {
    this.init();
    var ele = document.createElement('div'),
      isTouched = false,
      that = this,
      t = 0;
    ele.className = 'loadData';
    ele.innerHTML = '<div class="spinner"><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div></div>加载中';
    document.addEventListener('touchstart', function(ev) {
      document.body.style.transition = "";
      t = ev.changedTouches[0].clientY;
      isTouched = true;
      // ev.preventDefault();
    }, false);
    document.addEventListener('gesturechange', function(ev) {
      console.log(ev)
      ev.preventDefault();
    }, false);
    document.addEventListener('touchend', function(ev) {
      document.body.style.transition = "top .5s";
      document.body.style.top = '0px';
      isTouched = false;
    }, false);
    document.addEventListener('touchcancel', function(ev) {
      document.body.style.transition = "top .5s";
      document.body.style.top = '0px';
      isTouched = false;
      ev.preventDefault();
    }, false);
    document.addEventListener('touchmove', function(ev) {
      var foor = document.querySelector('.footer-interval'),
        loadData = document.querySelector('.loadData'),
        Y = ev.changedTouches[0].clientY;
      if (!!foor) {
        if (loadData == null) {
          document.body.insertBefore(ele, foor);
        }
      }
      if (isTouched) {
        if (t > Y && that.t < 10) {
          ev.preventDefault();
          (callback && typeof(callback) === "function") && callback(fn);
          document.body.style.position = 'relative';
          document.body.style.top = (Y - t) + 'px';
        }
      }
    }, false);
    return this;
  }

};
